<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=LTcdtaUhvwYYnvWd90tfvhBYBGgxmwbC"></script>
</head>

<body>
  <script>
    // BMap.LocalCity()   -   IP 定位的核心方法
    const myCity = new BMap.LocalCity();
    myCity.get(function (result) {
      const cityName = result.name;
      console.log(result);
    });
  </script>
</body>

</html>